package com.itzyf.pokemondata.fragment

import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.itzyf.pokemondata.R
import com.itzyf.pokemondata.activity.setting.RewardActivity
import com.tydic.baselibrary.fragment.BaseFragment

private const val ARG_PARAM1 = "type"

/**
 * @author 依风听雨
 * @version 创建时间：2019/04/30 08:49
 */
class PayFragment : BaseFragment() {

    private var type: Int = 0
    override fun initView(view: View?) {
        view?.let {
            view.setBackgroundColor(resources.getColor(if (type == 0) R.color.wechat else R.color.white))
            view.findViewById<TextView>(R.id.tvTips).setTextColor(if (type == 0) Color.WHITE else Color.BLACK)
            view.findViewById<ImageView>(R.id.ivPay).setImageResource(
                if (type == 0) R.drawable.ic_wechat else R.drawable.ic_zhifubao
            )
            view.findViewById<ImageView>(R.id.ivPay).setOnLongClickListener {
                (mActivity as RewardActivity).saveImage(type)
                return@setOnLongClickListener true
            }
        }


    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
            type = it.getInt(ARG_PARAM1)
        }
    }

    override fun getLayoutID() = R.layout.fragment_pay


    companion object {

        @JvmStatic
        fun newInstance(type: Int) =
            PayFragment().apply {
                arguments = Bundle().apply {
                    putInt(ARG_PARAM1, type)
                }
            }
    }
}